package com.leslie.app.mapper;

import com.leslie.app.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {
    List<User> findAll();

    User findById(Integer id);

    @Select("select * from tb_user where username=#{username}")
    User findByUserName(String username);

    @Insert("insert into tb_user(username, password, createTime, updateTime)" +
            " values(#{username}, #{password}, now(), now())")
    void add(String username, String password);

    int update(User user);
    int delete(Integer id);
}